import { Descriptions, Tooltip, message } from 'antd';
import { useMemo } from 'react';
import { RuleManageAPI } from '../common/type';
import MyIcon from '@/components/MyIcon';
import { EyeOutlined } from '@ant-design/icons';
import { renderPlanPriceDom, renderBoolOpenDom, renderRuleStyleDom, renderSupplyWayDom } from '../mconfig';
import { getColorTextLoadMapDom, getFileNameByPath, downloadTemplate, newGetFileNameNotType } from '@/utils';
const DesItem = Descriptions.Item;

export const DetailDrawerInfo: React.FC<RuleManageAPI.IDetailDrawerInfo> = ({ detailInfo, curRes }) => {
  /** 返回招标范本文件名称 */
  const bidTempFileName = useMemo(() => {
    return detailInfo?.bidTempFileURL ? getFileNameByPath(detailInfo?.bidTempFileURL) : '';
  }, [detailInfo?.bidTempFileURL]);

  return (
    <Descriptions bordered={true} size="small" column={4}>
      <DesItem
        span={4}
        label={
          <>
            <MyIcon type="icon-hetongguanli-" />
            &nbsp;规则标题
          </>
        }
      >
        <div>{detailInfo?.ruleTitle || '--'}</div>
      </DesItem>
      <DesItem
        span={4}
        label={
          <>
            <MyIcon type="icon-hetongxiangqing" />
            &nbsp;规则介绍
          </>
        }
      >
        {detailInfo?.ruleInfo || '--'}
      </DesItem>
      {/* <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-kaiqi" />
            &nbsp;&nbsp;是否启用
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.isOpen)}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-sanwei" />
            &nbsp;&nbsp;采购办法
          </span>
        }
      >
        {renderSupplyWayDom(detailInfo?.supplyWay)}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-guize" />
            &nbsp;&nbsp;采购规则
          </span>
        }
      >
        {renderRuleStyleDom(detailInfo?.ruleStyle)}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-xinzi" />
            &nbsp;&nbsp;预算费用
          </span>
        }
      >
        {renderPlanPriceDom(detailInfo?.ruleStyle, detailInfo?.planPriceMin, detailInfo?.planPriceMax)}
      </DesItem>

      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-chanpinguanli1" />
            &nbsp;&nbsp;采购类别
          </span>
        }
      >
        {(detailInfo?.supplyKindName && getColorTextLoadMapDom(detailInfo?.supplyKindName)) || '--'}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-leixing" />
            &nbsp;&nbsp;采购类型
          </span>
        }
      >
        {(detailInfo?.supplyTypeName && getColorTextLoadMapDom(detailInfo?.supplyTypeName)) || '--'}
      </DesItem> */}

      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-weimingmingwenjianjia_lanmu" />
            &nbsp;&nbsp;组织形式
          </span>
        }
      >
        {(detailInfo?.procureOrgName && getColorTextLoadMapDom(detailInfo?.procureOrgName)) || '--'}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-weimingmingwenjianjia_lanmu" />
            &nbsp;&nbsp;拟采方式
          </span>
        }
      >
        {(detailInfo?.procureDraftName && getColorTextLoadMapDom(detailInfo?.procureDraftName)) || '--'}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-fanganzhizuo_huaban" />
            &nbsp;&nbsp;招标范本文件
          </span>
        }
      >
        {detailInfo?.bidTempFileURL ? (
          <Tooltip title={bidTempFileName}>
            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
              <a
                onClick={() => {
                  message.success('下载中，请稍后...');
                  downloadTemplate('/purchaseStyleRuleController/downloadFile', bidTempFileName, detailInfo?.bidTempFileURL, () => {});
                }}
              >
                <MyIcon type="icon-file-text-fill" />
                &nbsp;
                {newGetFileNameNotType(bidTempFileName, 7)}
              </a>
            </div>
          </Tooltip>
        ) : (
          '--'
        )}
      </DesItem>
      {/* <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-weimingmingwenjianjia_lanmu" />
            &nbsp;&nbsp;可变更采购方式
          </span>
        }
      >
        {detailInfo?.procureReal || '--'}
      </DesItem>

      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-gongkaobei" />
            &nbsp;&nbsp;最少供应商数量
          </span>
        }
      >
        {detailInfo?.supplierMinNum || '0'}个
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-bumen" />
            &nbsp;&nbsp;归口部门
          </span>
        }
      >
        {detailInfo?.dutyDepartmentName || '--'}
      </DesItem>

      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-qianfa" />
            &nbsp;&nbsp;是否意向公开
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.needIntentFlag)}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-tiaocha" />
            &nbsp;&nbsp;是否签署合同
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.contractFlag)}
      </DesItem>

      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-biangengshenhe" />
            &nbsp;&nbsp;是否通过需求论证
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.needProofFlag)}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-gongchengyewu" />
            &nbsp;&nbsp;是否通过可研报告
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.needStudyFlag)}
      </DesItem>

      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-xiangmu" />
            &nbsp;&nbsp;是否通过项目建议书
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.needProjectFlag)}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-solution1" />
            &nbsp;&nbsp;是否通过第三方评审
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.needReviewFlag)}
      </DesItem>
      <DesItem
        span={2}
        label={
          <span>
            <MyIcon type="icon-zuhuguanli" />
            &nbsp;&nbsp;是否委托招标代理机构
          </span>
        }
      >
        {renderBoolOpenDom(detailInfo?.entrustFlag)}
      </DesItem> */}
      <DesItem
        span={2}
        label={
          <>
            <MyIcon type={'icon-user'} />
            &nbsp;联系人
          </>
        }
      >
        {detailInfo?.createrName || '--'}
      </DesItem>

      <DesItem
        span={2}
        label={
          <>
            <MyIcon type={'icon-time'} />
            &nbsp;联系时间
          </>
        }
      >
        {detailInfo?.createTime?.split(' ')?.[0] || '--'}
      </DesItem>
      <DesItem
        span={2}
        label={
          <>
            <MyIcon type={'icon-gangweitubiao'} />
            &nbsp;联系岗位
          </>
        }
      >
        {detailInfo?.createPositionName || '--'}
      </DesItem>

      <DesItem
        span={2}
        label={
          <>
            <MyIcon type={'icon-bumen'} />
            &nbsp;联系部门
          </>
        }
      >
        {detailInfo?.createDepartmentName || '--'}
      </DesItem>
      <DesItem
        span={2}
        label={
          <>
            <MyIcon type={'icon-gongsi'} />
            &nbsp;联系公司
          </>
        }
      >
        {detailInfo?.createCompanyName || '--'}
      </DesItem>
    </Descriptions>
  );
};
